﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:n="http://nRoute/schemas/2010/xaml"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows">
	
	<!-- LINK ITEM TEMPLATE, NOTE_ the use of navigation behaviour and the transparent background -->    
	<DataTemplate x:Key="LinkTemplate">
		<StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" MinWidth="106" MinHeight="35" 
			Cursor="Hand" Background="Transparent">
            <TextBlock Margin="20,9,8,7" VerticalAlignment="Center" FontFamily="Segoe UI Symbol" 
                           FontSize="13" Foreground="#FFFFFFFF" Text="{Binding Title}" TextWrapping="Wrap"/>
			<ItemsControl ItemsSource="{Binding ChildNodes}"
				ItemTemplate="{StaticResource LinkActionTemplate}"/>
		</StackPanel>
	</DataTemplate>
    
	<!-- LINK ACTION ITEM TEMPLATE, NOTE_ the use of ExecuteSiteMapNodeAction behaviour -->    
	<DataTemplate x:Key="LinkActionTemplate">
		<StackPanel Orientation="Horizontal" Margin="20,2,0,2" MinHeight="22">
			<Image Source="{Binding IconPath}" Height="18" Width="18"  VerticalAlignment="Center"/>
            <HyperlinkButton Content="{Binding Title}"
                             Margin="5,2,0,0"
                             IsTabStop="False"
                             FontFamily="Segoe UI Symbol"
                             FontSize="11"
                             Foreground="#FFFFFFFF"
                             VerticalAlignment="Center">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <n:ExecuteSiteMapNodeAction SiteMapNode="{Binding}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </HyperlinkButton>
        </StackPanel>
	</DataTemplate>
	
	<!-- LIST BOX STYLE -->
	<Style x:Key="LinksListBoxStyle" TargetType="ListBox">
		<Setter Property="Padding" Value="0"/>
		<Setter Property="Background" Value="#FFFFFFFF"/>
		<Setter Property="Foreground" Value="#FF000000"/>
		<Setter Property="HorizontalContentAlignment" Value="Left"/>
		<Setter Property="VerticalContentAlignment" Value="Top"/>
		<Setter Property="IsTabStop" Value="False"/>
		<Setter Property="BorderThickness" Value="1"/>
		<Setter Property="TabNavigation" Value="Once"/>
        <Setter Property="BorderBrush"  Value="{x:Null}" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="ListBox">
					<Grid>
						<ScrollViewer x:Name="ScrollViewer" BorderThickness="0" 
								BorderBrush="{x:Null}" Padding="0,0,0,0">
							<ItemsPresenter/>
						</ScrollViewer>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<!-- CONTAINER STYLE -->
	<Style x:Key="LinkContainerStyle" TargetType="ListBoxItem">        
		<Setter Property="HorizontalContentAlignment" Value="Left"/>
		<Setter Property="VerticalContentAlignment" Value="Top"/>
		<Setter Property="Background" Value="Transparent"/>
		<Setter Property="BorderThickness" Value="1"/>
		<Setter Property="TabNavigation" Value="Local"/>
        <Setter Property="Padding" Value="0,0,0,5"/>
        <Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="ListBoxItem">
					<Grid Background="{TemplateBinding Background}">
                        
                        <!-- VISUAL STATES -->
						<vsm:VisualStateManager.VisualStateGroups>
							<vsm:VisualStateGroup x:Name="CommonStates">
								<vsm:VisualState x:Name="Normal"/>
								<vsm:VisualState x:Name="MouseOver">
									<Storyboard>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="MouseOverVisual" 
                                                                       Storyboard.TargetProperty="Opacity">
											<SplineDoubleKeyFrame KeyTime="0" Value=".35"/>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</vsm:VisualState>
								<vsm:VisualState x:Name="Disabled">
									<Storyboard>
										<DoubleAnimationUsingKeyFrames Storyboard.TargetName="contentPresenter" 
                                                                       Storyboard.TargetProperty="Opacity">
											<SplineDoubleKeyFrame KeyTime="0" Value=".55"/>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</vsm:VisualState>
							</vsm:VisualStateGroup>
							<vsm:VisualStateGroup x:Name="SelectionStates">
								<vsm:VisualState x:Name="Unselected"/>
								<vsm:VisualState x:Name="Selected">
									<Storyboard>
										<DoubleAnimationUsingKeyFrames 
                                            Storyboard.TargetName="SelectedVisual" Storyboard.TargetProperty="Opacity">
											<SplineDoubleKeyFrame KeyTime="0" Value="1"/>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</vsm:VisualState>
							</vsm:VisualStateGroup>
							<vsm:VisualStateGroup x:Name="FocusStates">
								<vsm:VisualState x:Name="Focused"/>
								<vsm:VisualState x:Name="Unfocused"/>
							</vsm:VisualStateGroup>
						</vsm:VisualStateManager.VisualStateGroups>
                        
                        <!-- MOUSE OVER UNDERLAY -->
						<Rectangle x:Name="MouseOverVisual" Fill="#FFBADDE9" RadiusX="1" RadiusY="1" 
                                   IsHitTestVisible="False" Opacity="0" Cursor="Hand"/>
                        
                        <!-- SELECTED UNDERLAY -->
                        <Border BorderBrush="{x:Null}" BorderThickness="0,0,0,0" Background="{StaticResource SelectedLinkBkgBrush}"
                                x:Name="SelectedVisual" Opacity="0">
                            
                            <Border.Effect>
                                <DropShadowEffect BlurRadius="5" Color="#7F000000" Direction="-165" ShadowDepth="4"/>
                            </Border.Effect>
                            
                            <!-- SIDE TRIANGLE -->
                            <Path Fill="#FFFFFFFF" Stretch="Fill" Stroke="{x:Null}" HorizontalAlignment="Right" 
                                  Margin="0,12.763,0.002,0" Width="6.498" Height="11.334" VerticalAlignment="Top"
                                  UseLayoutRounding="False" Data="M105.60668,13.132615 L99.708,18.177011 L105.60668,23.310255"/>
                            
                        </Border>
                        
                        <!-- CONTENT -->
                        <ContentPresenter x:Name="contentPresenter" 
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                              Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" 
                              ContentTemplate="{TemplateBinding ContentTemplate}"/>
                        
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
</ResourceDictionary>